using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

using DataAccess;
using DataTransferObject;

namespace Business
{
    public enum BangCapBUSResult
    {
        OK,
        MABCERROR,
        TENBCERROR,
        DAOERROR
    }

    public class clsBangCapBUS
    {
        //Fields.
        private clsBangCapDAO bangCapDAO;
     

        //Constructors.
        public clsBangCapBUS()
        {
            this.bangCapDAO = new clsBangCapDAO();
        }

        #region Methods

        public BangCapBUSResult KiemTraRong(clsBangCapDTO obj)
        {
            if (obj.MaBC == "")
                return BangCapBUSResult.MABCERROR;
            if ((obj.TenBC == ""))
                return BangCapBUSResult.TENBCERROR;
            return BangCapBUSResult.OK;
        }

        public DataTable DanhSachBangCap()
        {
            return this.bangCapDAO.SelectAll();
        }

        public BangCapBUSResult ThemBangCap(clsBangCapDTO obj)
        {
            BangCapBUSResult check = KiemTraRong(obj);
            if (check != BangCapBUSResult.OK)
                return check;

            if (!this.bangCapDAO.Insert(obj))
                return BangCapBUSResult.DAOERROR;
            return BangCapBUSResult.OK;
        }

        public BangCapBUSResult SuaBangCap(clsBangCapDTO obj)
        {
            if (!this.bangCapDAO.Update(obj))
                return BangCapBUSResult.DAOERROR;
            return BangCapBUSResult.OK;
        }

        public BangCapBUSResult XoaBangCap(clsBangCapDTO obj)
        {
            if (!this.bangCapDAO.Delete(obj))
                return BangCapBUSResult.DAOERROR;
            return BangCapBUSResult.OK;
        }
        #endregion
    }
}
